import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductSpecsVO, ProductSpecsForm, ProductSpecsQuery } from '@/api/system/productSpecs/types';

/**
 * 查询产品规格，存储产品的规格参数列表
 * @param query
 * @returns {*}
 */

export const listProductSpecs = (query?: ProductSpecsQuery): AxiosPromise<ProductSpecsVO[]> => {
  return request({
    url: '/system/productSpecs/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品规格，存储产品的规格参数详细
 * @param id
 */
export const getProductSpecs = (id: string | number): AxiosPromise<ProductSpecsVO> => {
  return request({
    url: '/system/productSpecs/' + id,
    method: 'get'
  });
};

/**
 * 新增产品规格，存储产品的规格参数
 * @param data
 */
export const addProductSpecs = (data: ProductSpecsForm) => {
  return request({
    url: '/system/productSpecs',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品规格，存储产品的规格参数
 * @param data
 */
export const updateProductSpecs = (data: ProductSpecsForm) => {
  return request({
    url: '/system/productSpecs',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品规格，存储产品的规格参数
 * @param id
 */
export const delProductSpecs = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/productSpecs/' + id,
    method: 'delete'
  });
};
